<!--
* @description s
* @fileName 01.行内样式
* @author userName
* @date 2024-01-23 09:03:26
* @version V1.0.0
!-->
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>01.行内样式</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="handlerChangeStyle01">样式一</button>
        <button @click="handlerChangeStyle02">样式二</button>
        <div :style="style"></div>
        <div :style="{width,height,border}"></div>
        <hr>
        <div :style="{...style01,...style02}"></div>
        <hr>
        <div :style="[style01,style02]"></div>
    </div>

    <script>
        /*
        vue 中  行内样式支持对象的形式 
                {
                    key:value
                }
        */
        var vm = new Vue({
            data:{
                style:{
                    width: 300+"px",
                    height: 300+"px",
                    border: "solid"
                },
                width: 300+"px",
                height: 300+"px",
                border: "solid",
                style01:{
                    width: 300+"px",
                    height: 300+"px",
                    backgroundColor:"red"
                },
                style02:{
                    border: "solid"
                }
            },
            methods :{
                handlerChangeStyle01() {
                   // this.style.backgroundColor = 'red'
                    this.$set(this.style,"backgroundColor",'red')
                    // 强行渲染 页面
                   // this.$forceUpdate();

                } ,
                handlerChangeStyle02() {
                    this.style.backgroundColor = "yellow"
                     // 强行渲染 页面
                    this.$forceUpdate();
                } 
            }
        });
        vm.$mount("#app")
    </script>
</body>

</html>